/*
 * Copyright © 2012, United States Government, as represented by the
 * Administrator of the National Aeronautics and Space Administration.
 * All rights reserved.
 * 
 * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
 * under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0.
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
*/

#ifndef JSON_GOAL_TENSION_H
#define JSON_GOAL_TENSION_H

/**
 * @file JSONGoalTension.h
 * @brief A controller for the template class BaseSpineModelLearning
 * @author Brian Mirletz
 * @version 1.1.0
 * $Id$
 */

#include "examples/learningSpines/BaseSpineCPGControl.h"
#include "dev/btietz/TC_goal/JSONGoalControl.h"

#include <json/value.h>


/**
 * JSONGoalTension learns the parameters for a CPG system on a
 * spine like tensegrity structure specified as a BaseSpineModelLearning. Parameters are generated by
 * AnnealEvolution and used in the CPGEquations family of classes.
 * tgImpedanceController controllers are used for the detailed muscle control.
 * Due to the number of parameters, the learned parameters are split
 * into one config file for the nodes and another for the CPG's "edges"
 */
class JSONGoalTension : public JSONGoalControl
{
public:

    JSONGoalTension(JSONGoalControl::Config config,	
							std::string args,
							std::string resourcePath = "");
    
    virtual ~JSONGoalTension();
    
    virtual void onSetup(BaseSpineModelLearning& subject);
    
    virtual void onStep(BaseSpineModelLearning& subject, double dt);
    
    virtual void onTeardown(BaseSpineModelLearning& subject);
	
protected:

    virtual array_2D scaleNodeActions (Json::Value actions);
    
    virtual std::vector<double> getGoalFeedback(const BaseSpineModelGoal* subject);
    
    virtual std::vector<double> getFeedback(BaseSpineModelLearning& subject);    
    
    virtual void setupFeedbackWeights(array_2D nodeVals);
    
    array_2D feedbackWeights;
};

#endif // SPINE_FEEDBACK_CONTROL_H
